﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.UI
{
    class XEventModel
    {
        public Type PartType { get; private set; }
        public List<XEvent> EventList { get; private set; }
        public XEventModel(Type partType)
        {
            PartType = partType;
            EventList = new List<XEvent>();
        }

        public void AddEvent(XEvent @event)
        {
            bool isExist = false;
            foreach (var item in EventList)
            {
                if (item.Name == @event.Name)
                {
                    isExist = true;
                    break;
                }
            }
            if (!isExist)
            {
                EventList.Add(@event);
            }
        }
    }

    public class XEvent
    {
        /// <summary>
        /// 扩展事件名称
        /// </summary>
        public string Name { get; private set; }

        public XEventArgument[] Args { get; private set; }
        /// <summary>
        /// 名称
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="args">参数数组</param>
        public XEvent(string name, XEventArgument[] args)
        {
            Name = name;
            Args = args;
        }
    }

    public class XEventArgument
    {
        public string Name { get; set; }
        public Type Type{get;set;}

        public XEventArgument(string name, Type type)
        {
            this.Name = name;
            this.Type = type;
        }
    }
}
